/**
 * <copyright>
 * </copyright>
 *

 */
package ms.unicorn.language.languagedef.impl;

import ms.unicorn.language.languagedef.LabelSourceField;
import ms.unicorn.language.languagedef.LanguagedefPackage;
import ms.unicorn.language.languagedef.TagEntryDef;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Label Source Field</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.language.languagedef.impl.LabelSourceFieldImpl#isBuiltIn <em>Built In</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.LabelSourceFieldImpl#getName <em>Name</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.LabelSourceFieldImpl#getField <em>Field</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class LabelSourceFieldImpl extends MinimalEObjectImpl.Container implements LabelSourceField
{
  /**
   * The default value of the '{@link #isBuiltIn() <em>Built In</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isBuiltIn()
   * @generated
   * @ordered
   */
  protected static final boolean BUILT_IN_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isBuiltIn() <em>Built In</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isBuiltIn()
   * @generated
   * @ordered
   */
  protected boolean builtIn = BUILT_IN_EDEFAULT;

  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getField() <em>Field</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getField()
   * @generated
   * @ordered
   */
  protected TagEntryDef field;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected LabelSourceFieldImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LanguagedefPackage.Literals.LABEL_SOURCE_FIELD;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isBuiltIn()
  {
    return builtIn;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setBuiltIn(boolean newBuiltIn)
  {
    boolean oldBuiltIn = builtIn;
    builtIn = newBuiltIn;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.LABEL_SOURCE_FIELD__BUILT_IN, oldBuiltIn, builtIn));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.LABEL_SOURCE_FIELD__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TagEntryDef getField()
  {
    if (field != null && field.eIsProxy())
    {
      InternalEObject oldField = (InternalEObject)field;
      field = (TagEntryDef)eResolveProxy(oldField);
      if (field != oldField)
      {
        if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.RESOLVE, LanguagedefPackage.LABEL_SOURCE_FIELD__FIELD, oldField, field));
      }
    }
    return field;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public TagEntryDef basicGetField()
  {
    return field;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setField(TagEntryDef newField)
  {
    TagEntryDef oldField = field;
    field = newField;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.LABEL_SOURCE_FIELD__FIELD, oldField, field));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_SOURCE_FIELD__BUILT_IN:
        return isBuiltIn();
      case LanguagedefPackage.LABEL_SOURCE_FIELD__NAME:
        return getName();
      case LanguagedefPackage.LABEL_SOURCE_FIELD__FIELD:
        if (resolve) return getField();
        return basicGetField();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_SOURCE_FIELD__BUILT_IN:
        setBuiltIn((Boolean)newValue);
        return;
      case LanguagedefPackage.LABEL_SOURCE_FIELD__NAME:
        setName((String)newValue);
        return;
      case LanguagedefPackage.LABEL_SOURCE_FIELD__FIELD:
        setField((TagEntryDef)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_SOURCE_FIELD__BUILT_IN:
        setBuiltIn(BUILT_IN_EDEFAULT);
        return;
      case LanguagedefPackage.LABEL_SOURCE_FIELD__NAME:
        setName(NAME_EDEFAULT);
        return;
      case LanguagedefPackage.LABEL_SOURCE_FIELD__FIELD:
        setField((TagEntryDef)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_SOURCE_FIELD__BUILT_IN:
        return builtIn != BUILT_IN_EDEFAULT;
      case LanguagedefPackage.LABEL_SOURCE_FIELD__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case LanguagedefPackage.LABEL_SOURCE_FIELD__FIELD:
        return field != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (builtIn: ");
    result.append(builtIn);
    result.append(", name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //LabelSourceFieldImpl
